import { defineStore } from 'pinia'
interface Login {
    token: string | null
}
export const useLogin = defineStore({
    id: "useLogin",

    state: (): Login => {
        return {
            token: null
        }
    },
    // 开启持久化
    persist: {
        enabled: true,
        strategies: [
            {
                key: 'useLogin',  //自定义 Key值
                storage: sessionStorage,  // 选择存储方式
            },
        ],
    },
    actions: {
        SetToken(tokenStr: string) {
            this.token = tokenStr
        },
        removeToken() {
            this.token = null
        }
    }
})